<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Class: ReportesController</title>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
  <link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
  <script type="text/javascript">
  // <![CDATA[

  function popupCode( url ) {
    window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
  }

  function toggleCode( id ) {
    if ( document.getElementById )
      elem = document.getElementById( id );
    else if ( document.all )
      elem = eval( "document.all." + id );
    else
      return false;

    elemStyle = elem.style;
    
    if ( elemStyle.display != "block" ) {
      elemStyle.display = "block"
    } else {
      elemStyle.display = "none"
    }

    return true;
  }
  
  // Make codeblocks hidden by default
  document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
  
  // ]]>
  </script>

</head>
<body>



    <div id="classHeader">
        <table class="header-table">
        <tr class="top-aligned-row">
          <td><strong>Class</strong></td>
          <td class="class-name-in-header">ReportesController</td>
        </tr>
        <tr class="top-aligned-row">
            <td><strong>In:</strong></td>
            <td>
                <a href="../files/app/controllers/reportes_controller_rb.html">
                app/controllers/reportes_controller.rb
                </a>
        <br />
            </td>
        </tr>

        <tr class="top-aligned-row">
            <td><strong>Parent:</strong></td>
            <td>
                <a href="ApplicationController.html">
                ApplicationController
               </a>
            </td>
        </tr>
        </table>
    </div>
  <!-- banner header -->

  <div id="bodyContent">



  <div id="contextContent">



   </div>

    <div id="method-list">
      <h3 class="section-bar">Methods</h3>

      <div class="name-list">
      <a href="#M000013">create</a>&nbsp;&nbsp;
      <a href="#M000021">destroy</a>&nbsp;&nbsp;
      <a href="#M000019">edit</a>&nbsp;&nbsp;
      <a href="#M000016">get_chart</a>&nbsp;&nbsp;
      <a href="#M000018">get_equipo</a>&nbsp;&nbsp;
      <a href="#M000017">get_user</a>&nbsp;&nbsp;
      <a href="#M000020">index</a>&nbsp;&nbsp;
      <a href="#M000012">new</a>&nbsp;&nbsp;
      <a href="#M000015">show</a>&nbsp;&nbsp;
      <a href="#M000014">update</a>&nbsp;&nbsp;
      </div>
    </div>

  </div>


    <!-- if includes -->

    <div id="section">





      


    <!-- if method_list -->
    <div id="methods">
      <h3 class="section-bar">Public Instance methods</h3>

      <div id="method-M000013" class="method-detail">
        <a name="M000013"></a>

        <div class="method-heading">
          <a href="#M000013" class="method-signature">
          <span class="method-name">create</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000013-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000013-source">
<pre>
    <span class="ruby-comment cmt"># File app/controllers/reportes_controller.rb, line 17</span>
17:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">create</span>
18:     <span class="ruby-identifier">cookies</span>.<span class="ruby-identifier">delete</span> <span class="ruby-identifier">:auth_token</span>
19:     <span class="ruby-comment cmt"># protects against session fixation attacks, wreaks havoc with </span>
20:     <span class="ruby-comment cmt"># request forgery protection.</span>
21:     <span class="ruby-comment cmt"># uncomment at your own risk</span>
22:     <span class="ruby-comment cmt"># reset_session</span>
23:     <span class="ruby-ivar">@reporte</span> = <span class="ruby-constant">Reporte</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">params</span>[<span class="ruby-identifier">:reporte</span>])
24:  
25:     <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@reporte</span>.<span class="ruby-identifier">fecha_desde</span> <span class="ruby-operator">&gt;</span> <span class="ruby-ivar">@reporte</span>.<span class="ruby-identifier">fecha_hasta</span> <span class="ruby-keyword kw">then</span>
26:                 <span class="ruby-identifier">flash_error</span> <span class="ruby-identifier">:message</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">&quot;La Fecha Desde no puede ser menor a la Fecha Hasta&quot;</span>
27:                 <span class="ruby-identifier">render</span> <span class="ruby-identifier">:action</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">'new'</span>
28:                 <span class="ruby-keyword kw">else</span>            
29:                   <span class="ruby-ivar">@reporte</span>.<span class="ruby-identifier">save</span>
30:         <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@reporte</span>.<span class="ruby-identifier">errors</span>.<span class="ruby-identifier">empty?</span>
31:           <span class="ruby-identifier">redirect_back_or_default</span>(<span class="ruby-value str">'/reportes'</span>)
32:         <span class="ruby-keyword kw">else</span>               
33:           <span class="ruby-identifier">render</span> <span class="ruby-identifier">:action</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">'new'</span>
34:         <span class="ruby-keyword kw">end</span>
35:                 <span class="ruby-keyword kw">end</span>
36:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000021" class="method-detail">
        <a name="M000021"></a>

        <div class="method-heading">
          <a href="#M000021" class="method-signature">
          <span class="method-name">destroy</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
DELETE /reportes/1 DELETE /reportes/1.xml
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000021-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000021-source">
<pre>
     <span class="ruby-comment cmt"># File app/controllers/reportes_controller.rb, line 228</span>
228:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">destroy</span>
229:      
230:   
231:     <span class="ruby-ivar">@reporte</span> = <span class="ruby-constant">Reporte</span>.<span class="ruby-identifier">find</span>(<span class="ruby-identifier">params</span>[<span class="ruby-identifier">:id</span>])
232:     <span class="ruby-ivar">@reporte</span>.<span class="ruby-identifier">destroy</span>
233: 
234:     <span class="ruby-identifier">respond_to</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">format</span><span class="ruby-operator">|</span>
235:       <span class="ruby-identifier">format</span>.<span class="ruby-identifier">html</span> { <span class="ruby-identifier">redirect_to</span>(<span class="ruby-identifier">reportes_path</span>) }
236:       <span class="ruby-identifier">format</span>.<span class="ruby-identifier">xml</span>  { <span class="ruby-identifier">head</span> <span class="ruby-identifier">:ok</span> }
237:     <span class="ruby-keyword kw">end</span>
238:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000019" class="method-detail">
        <a name="M000019"></a>

        <div class="method-heading">
          <a href="#M000019" class="method-signature">
          <span class="method-name">edit</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
GET /reporte/1/edit
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000019-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000019-source">
<pre>
     <span class="ruby-comment cmt"># File app/controllers/reportes_controller.rb, line 211</span>
211:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">edit</span>
212:     <span class="ruby-ivar">@reporte</span> = <span class="ruby-constant">Reporte</span>.<span class="ruby-identifier">find</span>(<span class="ruby-identifier">params</span>[<span class="ruby-identifier">:id</span>])
213:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000016" class="method-detail">
        <a name="M000016"></a>

        <div class="method-heading">
          <a href="#M000016" class="method-signature">
          <span class="method-name">get_chart</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000016-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000016-source">
<pre>
    <span class="ruby-comment cmt"># File app/controllers/reportes_controller.rb, line 66</span>
66:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">get_chart</span>  
67:         <span class="ruby-identifier">resultado</span> = <span class="ruby-identifier">params</span>[<span class="ruby-identifier">:resultado</span>] 
68:         <span class="ruby-identifier">g</span> = <span class="ruby-constant">Gruff</span><span class="ruby-operator">::</span><span class="ruby-constant">Bar</span>.<span class="ruby-identifier">new</span>
69:         <span class="ruby-identifier">g</span>.<span class="ruby-identifier">theme</span> = {
70:    <span class="ruby-identifier">:colors</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-node">%w(orange red green white red)</span>,
71:    <span class="ruby-identifier">:marker_color</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">'black'</span>,
72:    <span class="ruby-identifier">:background_colors</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-node">%w(white white)</span>
73:  }
74: 
75:   
76:   <span class="ruby-identifier">g</span>.<span class="ruby-identifier">title</span> = <span class="ruby-value str">&quot;Performance&quot;</span> 
77:   <span class="ruby-keyword kw">if</span>    <span class="ruby-identifier">params</span>[<span class="ruby-identifier">:name</span>] <span class="ruby-keyword kw">then</span>
78:                 <span class="ruby-identifier">g</span>.<span class="ruby-identifier">title</span> <span class="ruby-operator">+=</span> <span class="ruby-value str">' de '</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">params</span>[<span class="ruby-identifier">:name</span>] 
79:         <span class="ruby-keyword kw">end</span>
80:   <span class="ruby-identifier">g</span>.<span class="ruby-identifier">data</span>(<span class="ruby-value str">&quot;Valores Actuales&quot;</span>, [<span class="ruby-identifier">resultado</span>[<span class="ruby-value str">'Promedio Movimientos'</span>].<span class="ruby-identifier">to_f</span>,<span class="ruby-identifier">resultado</span>[<span class="ruby-value str">'Promedio Reuniones'</span>].<span class="ruby-identifier">to_f</span>])
81:   
82:   <span class="ruby-ivar">@metrica</span> = <span class="ruby-constant">Metrica</span>.<span class="ruby-identifier">find</span>(<span class="ruby-identifier">:last</span>)
83:   
84:   <span class="ruby-identifier">g</span>.<span class="ruby-identifier">data</span>(<span class="ruby-value str">&quot;Referencia&quot;</span>, [<span class="ruby-ivar">@metrica</span>.<span class="ruby-identifier">movimientos</span>,<span class="ruby-ivar">@metrica</span>.<span class="ruby-identifier">reuniones</span>])
85:   <span class="ruby-identifier">g</span>.<span class="ruby-identifier">labels</span> = {<span class="ruby-value">0</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">'Movimientos'</span>, <span class="ruby-value">1</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">'Reuniones'</span>}
86:   <span class="ruby-identifier">g</span>.<span class="ruby-identifier">write</span>(<span class="ruby-value str">'public/images/chart_temp.png'</span>)       
87:           <span class="ruby-identifier">respond_to</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">format</span><span class="ruby-operator">|</span>
88:       <span class="ruby-identifier">format</span>.<span class="ruby-identifier">html</span> <span class="ruby-comment cmt"># index.html.erb</span>
89:       <span class="ruby-identifier">format</span>.<span class="ruby-identifier">xml</span>  { <span class="ruby-identifier">render</span> <span class="ruby-identifier">:partial</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">&quot;get_chart&quot;</span> }
90:     <span class="ruby-keyword kw">end</span> 
91:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000018" class="method-detail">
        <a name="M000018"></a>

        <div class="method-heading">
          <a href="#M000018" class="method-signature">
          <span class="method-name">get_equipo</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000018-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000018-source">
<pre>
     <span class="ruby-comment cmt"># File app/controllers/reportes_controller.rb, line 138</span>
138:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">get_equipo</span>
139:   
140:   <span class="ruby-ivar">@reporte</span> = <span class="ruby-constant">Reporte</span>.<span class="ruby-identifier">find</span>(<span class="ruby-identifier">params</span>[<span class="ruby-identifier">:id</span>]) 
141:   <span class="ruby-ivar">@users</span> = <span class="ruby-constant">User</span>.<span class="ruby-identifier">find</span>(<span class="ruby-identifier">:all</span>, <span class="ruby-identifier">:conditions</span> =<span class="ruby-operator">&gt;</span> [<span class="ruby-value str">'equipo_id = ?'</span>,<span class="ruby-ivar">@reporte</span>.<span class="ruby-identifier">equipo_id</span>]).<span class="ruby-identifier">collect</span>(<span class="ruby-operator">&amp;</span><span class="ruby-identifier">:id</span>)   
142:         <span class="ruby-ivar">@users_all</span> = <span class="ruby-constant">User</span>.<span class="ruby-identifier">find</span>(<span class="ruby-identifier">:all</span>, <span class="ruby-identifier">:conditions</span> =<span class="ruby-operator">&gt;</span> [<span class="ruby-value str">'equipo_id = ?'</span>,<span class="ruby-ivar">@reporte</span>.<span class="ruby-identifier">equipo_id</span>])        
143:         
144:         <span class="ruby-ivar">@cuentas</span> = <span class="ruby-constant">Comunicacion</span>.<span class="ruby-identifier">find</span>(<span class="ruby-identifier">:all</span>,  <span class="ruby-identifier">:conditions</span> =<span class="ruby-operator">&gt;</span> [<span class="ruby-value str">'fecha &gt;= ? AND fecha &lt;= ? AND user_id in (?) AND type = ?'</span>,<span class="ruby-ivar">@reporte</span>.<span class="ruby-identifier">fecha_desde</span>,<span class="ruby-ivar">@reporte</span>.<span class="ruby-identifier">fecha_hasta</span>,<span class="ruby-ivar">@users</span>,<span class="ruby-value str">&quot;Venta&quot;</span> ]).<span class="ruby-identifier">collect</span>(<span class="ruby-operator">&amp;</span><span class="ruby-identifier">:cuenta_id</span>) 
145:          
146:   <span class="ruby-ivar">@comunicaciones</span> = <span class="ruby-constant">Comunicacion</span>.<span class="ruby-identifier">find</span>(<span class="ruby-identifier">:all</span>,<span class="ruby-identifier">:order</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">&quot;user_id,type&quot;</span>, <span class="ruby-identifier">:conditions</span> =<span class="ruby-operator">&gt;</span> [<span class="ruby-value str">'cuenta_id in (?) AND fecha &gt;= ? AND fecha &lt;= ? AND user_id in (?)'</span>, <span class="ruby-ivar">@cuentas</span>,<span class="ruby-ivar">@reporte</span>.<span class="ruby-identifier">fecha_desde</span>, <span class="ruby-ivar">@reporte</span>.<span class="ruby-identifier">fecha_hasta</span>, <span class="ruby-ivar">@users</span> ] )
147:         
148:         <span class="ruby-ivar">@res</span> = <span class="ruby-constant">Hash</span>.<span class="ruby-identifier">new</span>
149:         
150:         <span class="ruby-keyword kw">for</span> <span class="ruby-identifier">user</span> <span class="ruby-keyword kw">in</span> <span class="ruby-ivar">@users_all</span>
151:                 <span class="ruby-ivar">@resultado</span> = <span class="ruby-constant">Hash</span>.<span class="ruby-identifier">new</span>
152:                 
153:                 <span class="ruby-keyword kw">for</span> <span class="ruby-identifier">comunicacion</span> <span class="ruby-keyword kw">in</span> <span class="ruby-ivar">@comunicaciones</span> 
154:                  <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">comunicacion</span>.<span class="ruby-identifier">user_id</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">user</span>.<span class="ruby-identifier">id</span>  
155:                      <span class="ruby-identifier">resul</span> = <span class="ruby-ivar">@resultado</span>[<span class="ruby-identifier">comunicacion</span>.<span class="ruby-identifier">type</span>].<span class="ruby-identifier">to_i</span>
156:                      <span class="ruby-identifier">resul</span> <span class="ruby-operator">+=</span> <span class="ruby-value">1</span>
157:                      <span class="ruby-ivar">@resultado</span>[<span class="ruby-identifier">comunicacion</span>.<span class="ruby-identifier">type</span>] = <span class="ruby-identifier">resul</span>
158:          <span class="ruby-keyword kw">end</span>               
159:                 <span class="ruby-keyword kw">end</span>
160:                 <span class="ruby-ivar">@res</span>[<span class="ruby-identifier">user</span>.<span class="ruby-identifier">name</span>] = <span class="ruby-ivar">@resultado</span> 
161:         <span class="ruby-keyword kw">end</span>     
162: 
163:         <span class="ruby-keyword kw">for</span> <span class="ruby-identifier">user</span> <span class="ruby-keyword kw">in</span> <span class="ruby-ivar">@users_all</span>
164:           <span class="ruby-ivar">@resultado</span> = <span class="ruby-constant">Hash</span>.<span class="ruby-identifier">new</span>
165:                 <span class="ruby-ivar">@resultado</span> = <span class="ruby-ivar">@res</span>[<span class="ruby-identifier">user</span>.<span class="ruby-identifier">name</span>]  
166:                 <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@resultado</span>[<span class="ruby-value str">&quot;Movimiento&quot;</span>].<span class="ruby-identifier">to_i</span> <span class="ruby-operator">==</span> <span class="ruby-value">0</span> <span class="ruby-keyword kw">then</span>
167:                         <span class="ruby-ivar">@resultado</span>[<span class="ruby-value str">&quot;Movimiento&quot;</span>] = <span class="ruby-value">0</span>
168:                 <span class="ruby-keyword kw">end</span>
169:                 <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@resultado</span>[<span class="ruby-value str">&quot;Reunion&quot;</span>].<span class="ruby-identifier">to_i</span> <span class="ruby-operator">==</span> <span class="ruby-value">0</span> <span class="ruby-keyword kw">then</span>
170:                         <span class="ruby-ivar">@resultado</span>[<span class="ruby-value str">&quot;Reunion&quot;</span>] = <span class="ruby-value">0</span>
171:                 <span class="ruby-keyword kw">end</span>
172:                 <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@resultado</span>[<span class="ruby-value str">&quot;Venta&quot;</span>].<span class="ruby-identifier">to_i</span> <span class="ruby-operator">==</span> <span class="ruby-value">0</span> <span class="ruby-keyword kw">then</span>
173:                         <span class="ruby-ivar">@resultado</span>[<span class="ruby-value str">&quot;Venta&quot;</span>] = <span class="ruby-value">0</span>
174:                 <span class="ruby-keyword kw">end</span>
175:                                         
176:     <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@resultado</span>[<span class="ruby-value str">&quot;Venta&quot;</span>] <span class="ruby-operator">==</span> <span class="ruby-value">0</span> <span class="ruby-keyword kw">then</span>
177:       <span class="ruby-ivar">@resultado</span>[<span class="ruby-value str">'Promedio Movimientos'</span>] = <span class="ruby-value">0</span>            
178:         <span class="ruby-ivar">@resultado</span>[<span class="ruby-value str">'Promedio Reuniones'</span>] = <span class="ruby-value">0</span>
179:     <span class="ruby-keyword kw">else</span>    
180:                   <span class="ruby-ivar">@resultado</span>[<span class="ruby-value str">&quot;Promedio Movimientos&quot;</span>] = <span class="ruby-ivar">@resultado</span>[<span class="ruby-value str">&quot;Movimiento&quot;</span>].<span class="ruby-identifier">to_f</span> <span class="ruby-operator">/</span> <span class="ruby-ivar">@resultado</span>[<span class="ruby-value str">&quot;Venta&quot;</span>].<span class="ruby-identifier">to_f</span>                
181:                   <span class="ruby-ivar">@resultado</span>[<span class="ruby-value str">&quot;Promedio Reuniones&quot;</span>] = <span class="ruby-ivar">@resultado</span>[<span class="ruby-value str">&quot;Reunion&quot;</span>].<span class="ruby-identifier">to_f</span> <span class="ruby-operator">/</span> <span class="ruby-ivar">@resultado</span>[<span class="ruby-value str">&quot;Venta&quot;</span>].<span class="ruby-identifier">to_f</span> 
182:     <span class="ruby-keyword kw">end</span>       
183:     <span class="ruby-ivar">@res</span>[<span class="ruby-identifier">user</span>.<span class="ruby-identifier">name</span>] = <span class="ruby-ivar">@resultado</span>    
184:   <span class="ruby-keyword kw">end</span>
185:                 
186:         <span class="ruby-ivar">@promedio</span> = <span class="ruby-constant">Hash</span>.<span class="ruby-identifier">new</span>
187:         
188:         <span class="ruby-identifier">total_movimientos</span> = <span class="ruby-value">0</span><span class="ruby-value">.0</span>
189:         <span class="ruby-identifier">total_reuniones</span> = <span class="ruby-value">0</span><span class="ruby-value">.0</span>
190:         
191:         <span class="ruby-ivar">@res</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">key</span>, <span class="ruby-identifier">value</span><span class="ruby-operator">|</span>
192:                 <span class="ruby-ivar">@parcial</span> = <span class="ruby-identifier">value</span>
193:                 <span class="ruby-identifier">total_movimientos</span> <span class="ruby-operator">+=</span> <span class="ruby-ivar">@parcial</span>[<span class="ruby-value str">'Promedio Movimientos'</span>].<span class="ruby-identifier">to_f</span>
194:                 <span class="ruby-identifier">total_reuniones</span> <span class="ruby-operator">+=</span> <span class="ruby-ivar">@parcial</span>[<span class="ruby-value str">'Promedio Reuniones'</span>].<span class="ruby-identifier">to_f</span>        
195:         <span class="ruby-keyword kw">end</span>
196:         
197:         <span class="ruby-ivar">@promedio</span>[<span class="ruby-value str">'Promedio Movimientos'</span>] = <span class="ruby-identifier">total_movimientos</span> <span class="ruby-operator">/</span> <span class="ruby-ivar">@res</span>.<span class="ruby-identifier">size</span>.<span class="ruby-identifier">to_f</span>
198:         <span class="ruby-ivar">@promedio</span>[<span class="ruby-value str">'Promedio Reuniones'</span>] = <span class="ruby-identifier">total_reuniones</span> <span class="ruby-operator">/</span> <span class="ruby-ivar">@res</span>.<span class="ruby-identifier">size</span>.<span class="ruby-identifier">to_f</span>     
199:                 
200:         <span class="ruby-ivar">@nombre_equipo</span> = <span class="ruby-ivar">@reporte</span>.<span class="ruby-identifier">equipo</span>.<span class="ruby-identifier">nombre</span>
201:                 
202:   <span class="ruby-identifier">respond_to</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">format</span><span class="ruby-operator">|</span>
203:      <span class="ruby-identifier">format</span>.<span class="ruby-identifier">html</span> <span class="ruby-comment cmt"># index.html.erb</span>
204:      <span class="ruby-identifier">format</span>.<span class="ruby-identifier">xml</span>  { <span class="ruby-identifier">render</span> <span class="ruby-identifier">:partial</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">&quot;resultado&quot;</span>, <span class="ruby-identifier">:locals</span> =<span class="ruby-operator">&gt;</span> { <span class="ruby-identifier">:res</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-ivar">@res</span>, <span class="ruby-identifier">:promedio</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-ivar">@promedio</span>, <span class="ruby-identifier">:nombre_equipo</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-ivar">@nombre_equipo</span> } }
205:   <span class="ruby-keyword kw">end</span>    
206:         
207:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000017" class="method-detail">
        <a name="M000017"></a>

        <div class="method-heading">
          <a href="#M000017" class="method-signature">
          <span class="method-name">get_user</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000017-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000017-source">
<pre>
     <span class="ruby-comment cmt"># File app/controllers/reportes_controller.rb, line 94</span>
 94:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">get_user</span>
 95:         <span class="ruby-ivar">@reporte</span> = <span class="ruby-constant">Reporte</span>.<span class="ruby-identifier">find</span>(<span class="ruby-identifier">params</span>[<span class="ruby-identifier">:id</span>])          
 96:         <span class="ruby-ivar">@cuentas</span> = <span class="ruby-constant">Comunicacion</span>.<span class="ruby-identifier">find</span>(<span class="ruby-identifier">:all</span>,  <span class="ruby-identifier">:conditions</span> =<span class="ruby-operator">&gt;</span> [<span class="ruby-value str">'fecha &gt;= ? AND fecha &lt;= ? AND user_id = ? AND type = ?'</span>,<span class="ruby-ivar">@reporte</span>.<span class="ruby-identifier">fecha_desde</span>,<span class="ruby-ivar">@reporte</span>.<span class="ruby-identifier">fecha_hasta</span>,<span class="ruby-ivar">@reporte</span>.<span class="ruby-identifier">user_id</span>,<span class="ruby-value str">&quot;Venta&quot;</span> ] ).<span class="ruby-identifier">collect</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">comunicacion</span><span class="ruby-operator">|</span>[ <span class="ruby-identifier">comunicacion</span>.<span class="ruby-identifier">cuenta</span>.<span class="ruby-identifier">id</span>] }
 97:         
 98:          <span class="ruby-ivar">@comunicaciones</span> = <span class="ruby-constant">Comunicacion</span>.<span class="ruby-identifier">find</span>(<span class="ruby-identifier">:all</span>,<span class="ruby-identifier">:conditions</span> =<span class="ruby-operator">&gt;</span> [<span class="ruby-value str">'fecha &gt;= ? AND fecha &lt;= ? AND user_id = ?'</span>, <span class="ruby-ivar">@reporte</span>.<span class="ruby-identifier">fecha_desde</span>, <span class="ruby-ivar">@reporte</span>.<span class="ruby-identifier">fecha_hasta</span>, <span class="ruby-ivar">@reporte</span>.<span class="ruby-identifier">user_id</span> ] )
 99:         
100:  
101:         <span class="ruby-ivar">@resultado</span> = <span class="ruby-constant">Hash</span>.<span class="ruby-identifier">new</span> 
102:          
103:         <span class="ruby-keyword kw">for</span> <span class="ruby-identifier">comunicacion</span> <span class="ruby-keyword kw">in</span> <span class="ruby-ivar">@comunicaciones</span> 
104:          <span class="ruby-identifier">resul</span> = <span class="ruby-ivar">@resultado</span>[<span class="ruby-identifier">comunicacion</span>.<span class="ruby-identifier">type</span>].<span class="ruby-identifier">to_i</span>
105:          <span class="ruby-identifier">resul</span> <span class="ruby-operator">+=</span> <span class="ruby-value">1</span>
106:          <span class="ruby-ivar">@resultado</span>[<span class="ruby-identifier">comunicacion</span>.<span class="ruby-identifier">type</span>] = <span class="ruby-identifier">resul</span>           
107:         <span class="ruby-keyword kw">end</span> 
108:         
109:   <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@resultado</span>[<span class="ruby-constant">Movimiento</span>].<span class="ruby-identifier">to_i</span> <span class="ruby-operator">==</span> <span class="ruby-value">0</span> <span class="ruby-keyword kw">then</span>
110:                 <span class="ruby-ivar">@resultado</span>[<span class="ruby-constant">Movimiento</span>] = <span class="ruby-value">0</span>
111:         <span class="ruby-keyword kw">end</span>
112:         <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@resultado</span>[<span class="ruby-constant">Reunion</span>].<span class="ruby-identifier">to_i</span> <span class="ruby-operator">==</span> <span class="ruby-value">0</span> <span class="ruby-keyword kw">then</span>
113:                 <span class="ruby-ivar">@resultado</span>[<span class="ruby-constant">Reunion</span>] = <span class="ruby-value">0</span>
114:         <span class="ruby-keyword kw">end</span>
115:         <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@resultado</span>[<span class="ruby-constant">Venta</span>].<span class="ruby-identifier">to_i</span> <span class="ruby-operator">==</span> <span class="ruby-value">0</span> <span class="ruby-keyword kw">then</span>
116:                 <span class="ruby-ivar">@resultado</span>[<span class="ruby-constant">Venta</span>] = <span class="ruby-value">0</span>
117:         <span class="ruby-keyword kw">end</span>
118:         
119:         
120:         <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@resultado</span>[<span class="ruby-constant">Venta</span>] <span class="ruby-operator">!=</span> <span class="ruby-value">0</span> <span class="ruby-keyword kw">then</span>
121:                 <span class="ruby-ivar">@resultado</span>[<span class="ruby-value str">'Promedio Movimientos'</span>] = <span class="ruby-ivar">@resultado</span>[<span class="ruby-constant">Movimiento</span>].<span class="ruby-identifier">to_f</span> <span class="ruby-operator">/</span> <span class="ruby-ivar">@resultado</span>[<span class="ruby-constant">Venta</span>].<span class="ruby-identifier">to_f</span>
122:                 <span class="ruby-ivar">@resultado</span>[<span class="ruby-value str">'Promedio Reuniones'</span>] = <span class="ruby-ivar">@resultado</span>[<span class="ruby-constant">Reunion</span>].<span class="ruby-identifier">to_f</span> <span class="ruby-operator">/</span> <span class="ruby-ivar">@resultado</span>[<span class="ruby-constant">Venta</span>].<span class="ruby-identifier">to_f</span>
123:   <span class="ruby-keyword kw">else</span>
124:         <span class="ruby-ivar">@resultado</span>[<span class="ruby-value str">'Promedio Movimientos'</span>] = <span class="ruby-value">0</span>       
125:         <span class="ruby-ivar">@resultado</span>[<span class="ruby-value str">'Promedio Reuniones'</span>] = <span class="ruby-value">0</span>  
126:   <span class="ruby-keyword kw">end</span>
127:          
128:         <span class="ruby-ivar">@nombre_user</span> = <span class="ruby-ivar">@reporte</span>.<span class="ruby-identifier">user</span>.<span class="ruby-identifier">name</span> 
129:          
130:          <span class="ruby-identifier">respond_to</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">format</span><span class="ruby-operator">|</span>
131:       <span class="ruby-identifier">format</span>.<span class="ruby-identifier">html</span> <span class="ruby-comment cmt"># index.html.erb</span>
132:       <span class="ruby-identifier">format</span>.<span class="ruby-identifier">xml</span>  { <span class="ruby-identifier">render</span> <span class="ruby-identifier">:partial</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">&quot;resultado&quot;</span>, <span class="ruby-identifier">:locals</span> =<span class="ruby-operator">&gt;</span> { <span class="ruby-identifier">:resultado</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-ivar">@resultado</span>, <span class="ruby-identifier">:nombre_user</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-ivar">@nombre_user</span> } }
133:     <span class="ruby-keyword kw">end</span>  
134:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000020" class="method-detail">
        <a name="M000020"></a>

        <div class="method-heading">
          <a href="#M000020" class="method-signature">
          <span class="method-name">index</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000020-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000020-source">
<pre>
     <span class="ruby-comment cmt"># File app/controllers/reportes_controller.rb, line 215</span>
215:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">index</span>
216:     <span class="ruby-ivar">@reporte_usuarios</span> = <span class="ruby-constant">Reporte</span>.<span class="ruby-identifier">search_usuarios_all</span>(<span class="ruby-identifier">params</span>[<span class="ruby-identifier">:search</span>],<span class="ruby-identifier">params</span>[<span class="ruby-identifier">:user_page</span>])
217:                 <span class="ruby-ivar">@reporte_equipos</span> = <span class="ruby-constant">Reporte</span>.<span class="ruby-identifier">search_equipos_all</span>(<span class="ruby-identifier">params</span>[<span class="ruby-identifier">:search</span>],<span class="ruby-identifier">params</span>[<span class="ruby-identifier">:equipo_page</span>])
218: 
219:     <span class="ruby-identifier">respond_to</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">format</span><span class="ruby-operator">|</span>
220:      <span class="ruby-identifier">format</span>.<span class="ruby-identifier">html</span> <span class="ruby-comment cmt"># index.html.erb</span>
221:       <span class="ruby-identifier">format</span>.<span class="ruby-identifier">xml</span>  { <span class="ruby-identifier">render</span> <span class="ruby-identifier">:xml</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-ivar">@reporte</span> }
222:     <span class="ruby-keyword kw">end</span>
223:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000012" class="method-detail">
        <a name="M000012"></a>

        <div class="method-heading">
          <a href="#M000012" class="method-signature">
          <span class="method-name">new</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
render new.rhtml
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000012-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000012-source">
<pre>
    <span class="ruby-comment cmt"># File app/controllers/reportes_controller.rb, line 8</span>
 8:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">new</span>
 9:         <span class="ruby-ivar">@reporte</span> = <span class="ruby-constant">Reporte</span>.<span class="ruby-identifier">new</span>
10:     
11:     <span class="ruby-identifier">respond_to</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">format</span><span class="ruby-operator">|</span>
12:       <span class="ruby-identifier">format</span>.<span class="ruby-identifier">html</span> 
13:       <span class="ruby-identifier">format</span>.<span class="ruby-identifier">xml</span>  { <span class="ruby-identifier">render</span> <span class="ruby-identifier">:xml</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-ivar">@reporte</span> }
14:     <span class="ruby-keyword kw">end</span>
15:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000015" class="method-detail">
        <a name="M000015"></a>

        <div class="method-heading">
          <a href="#M000015" class="method-signature">
          <span class="method-name">show</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000015-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000015-source">
<pre>
    <span class="ruby-comment cmt"># File app/controllers/reportes_controller.rb, line 57</span>
57:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">show</span>
58:     <span class="ruby-ivar">@reporte</span> = <span class="ruby-constant">Reporte</span>.<span class="ruby-identifier">find</span>(<span class="ruby-identifier">params</span>[<span class="ruby-identifier">:id</span>])
59: 
60:     <span class="ruby-identifier">respond_to</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">format</span><span class="ruby-operator">|</span>
61:       <span class="ruby-identifier">format</span>.<span class="ruby-identifier">html</span> <span class="ruby-comment cmt"># show.html.erb</span>
62:       <span class="ruby-identifier">format</span>.<span class="ruby-identifier">xml</span>  { <span class="ruby-identifier">render</span> <span class="ruby-identifier">:xml</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-ivar">@reporte</span> }
63:     <span class="ruby-keyword kw">end</span> 
64:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000014" class="method-detail">
        <a name="M000014"></a>

        <div class="method-heading">
          <a href="#M000014" class="method-signature">
          <span class="method-name">update</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000014-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000014-source">
<pre>
    <span class="ruby-comment cmt"># File app/controllers/reportes_controller.rb, line 38</span>
38:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">update</span>
39:     <span class="ruby-keyword kw">if</span> <span class="ruby-operator">!</span><span class="ruby-constant">Reporte</span>.<span class="ruby-identifier">get_mod_reporte</span>(<span class="ruby-ivar">@current_user</span>) <span class="ruby-keyword kw">then</span>
40:                 <span class="ruby-identifier">redirect_to</span>(<span class="ruby-value str">'/reportes'</span>)                    
41:                 <span class="ruby-keyword kw">else</span>
42:     
43:     <span class="ruby-ivar">@reporte</span> = <span class="ruby-constant">Reporte</span>.<span class="ruby-identifier">find</span>(<span class="ruby-identifier">params</span>[<span class="ruby-identifier">:id</span>])
44:     <span class="ruby-identifier">respond_to</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">format</span><span class="ruby-operator">|</span>
45:       <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@reporte</span>.<span class="ruby-identifier">update_attributes</span>(<span class="ruby-identifier">params</span>[<span class="ruby-identifier">:reporte</span>])
46:         <span class="ruby-identifier">flash</span>[<span class="ruby-identifier">:notice</span>] = <span class="ruby-value str">'Reporte was updated.'</span>
47:         <span class="ruby-identifier">format</span>.<span class="ruby-identifier">html</span> { <span class="ruby-identifier">redirect_to</span>(<span class="ruby-identifier">reportes_path</span>) }
48:         <span class="ruby-identifier">format</span>.<span class="ruby-identifier">xml</span>  { <span class="ruby-identifier">head</span> <span class="ruby-identifier">:ok</span> }
49:       <span class="ruby-keyword kw">else</span>
50:         <span class="ruby-identifier">format</span>.<span class="ruby-identifier">html</span> { <span class="ruby-identifier">render</span> <span class="ruby-identifier">:action</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">&quot;edit&quot;</span> }
51:         <span class="ruby-identifier">format</span>.<span class="ruby-identifier">xml</span>  { <span class="ruby-identifier">render</span> <span class="ruby-identifier">:xml</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-ivar">@reporte</span>.<span class="ruby-identifier">errors</span>, <span class="ruby-identifier">:status</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">:unprocessable_entity</span> }
52:       <span class="ruby-keyword kw">end</span>
53:     <span class="ruby-keyword kw">end</span>
54:     <span class="ruby-keyword kw">end</span>
55:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>


    </div>


  </div>


<div id="validator-badges">
  <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>

</body>
</html>